package remote.adapters;

import remote.controllers.BaseController;
import remote.activities.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;

public class ImageViewAdapter extends BaseAdapter
{
	private Context _context;
	private BaseController _controller;
	private int[] _drawables = { R.drawable.ic_volume_off, 		R.drawable.ic_volume_low, 		R.drawable.ic_volume,
								 R.drawable.ic_media_previous, 	R.drawable.ic_media_play_pause,	R.drawable.ic_media_next,
								 R.drawable.ic_media_rew, 		R.drawable.ic_media_stop, 		R.drawable.ic_media_ff };
	
	public ImageViewAdapter(Context context, BaseController controller)
	{
		super();
		
		_context = context;
		_controller = controller;
	}
	
	@Override
	public int getCount()
	{
		return _drawables.length;
	}

	@Override
	public Object getItem(int position)
	{
		return _drawables[position];
	}

	@Override
	public long getItemId(int position)
	{
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		ImageView imageView;
		
        if (convertView == null)
        {
        	imageView = new ImageView(_context);
        	imageView.setBackgroundColor(android.R.color.transparent);
        	imageView.setLayoutParams(new GridView.LayoutParams(50, 50));
        	imageView.setScaleType(ImageButton.ScaleType.CENTER);
        }
        else
        	imageView = (ImageView)convertView;
        
        imageView.setImageResource(_drawables[position]);
        imageView.setId(_drawables[position]);
        imageView.setClickable(true);
        imageView.setOnClickListener(_controller);
        imageView.setOnTouchListener(_controller);
        return imageView;

	}

}
